
*******************************************************************************************
*******************************************************************************************
******************** Reclassification Risk in the Small Group Health Insurance Market
******************* by Sebastian Fleitas, Gautam Gowrisankaran and Anthony Lo Sasso 
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************
******************** Table D1
*******************************************************************************************
*******************************************************************************************
*******************************************************************************************


cd "~/Dropbox/ReclassificationRisk/"
use database_individual_level.dta, replace 


**************************************************************************************************
** BEGINING OF USIC ESTIMATES
** TWO STEP REGRESSION USING THIS SAMPLE (ROBUSTNESS ON LEAVING THE SAMPLE) **
**************************************************************************************************
tsset mbr_sys_id year
egen stderrorscluster = group(customer_number year)
gen SEX = (gdr_cd=="F")
gen industry = substr(sic_cd,1,1)
tab industry, gen(industy_dummy)
**************************************************************************************************
local conditions "lagged_code_hypertension lagged_code_heartfailure lagged_chronic_ami laggeed_code_respfailure  lagged_code_brainhemorr lagged_chronic_cancer lagged_chronic_diabetes lagged_code_asthma" 
mkspline reg16 1 reg17 = mean_pred_riskscore_rp 
*if year==2015 /*making the spline on the delta for 2015, cross section estimate */
*gen reg1 =  mean_pred_riskscore_rp 
gen reg2 = laggedscore
gen reg3 = age 
gen reg4 = SEX
gen reg5 = industy_dummy1 
gen reg6 = industy_dummy2
gen reg7 = industy_dummy3
gen reg8 = industy_dummy4 
gen reg9 = industy_dummy5
gen reg10 = industy_dummy6
gen reg11 = industy_dummy7
gen reg12 = industy_dummy8
gen reg13 = industy_dummy9
gen reg14 = industy_dummy10
gen reg15 = numpeople
probit exit_new reg* if year==2014, cluster(stderrorscluster) noconstant
forvalues i=2/17 {
scalar coeffprobit`i' = _b[reg`i']
}
*probit exit_new laggedscore mean_pred_riskscore_rp age SEX industy_dummy* numpeople if year==2014, cluster(stderrorscluster) noconstant
local n_probit = e(N)
matrix V = e(V)* `n_probit'
*ivprobit exit_new (laggedscore mean_pred_riskscore_rp = laggedscore_ORS mean_ORS_riskscore_rp) age SEX industy_dummy* numpeople if year==2014, cluster(stderrorscluster) 
margins, dydx(*)
predict linear_index, xb
gen prob_leaving = normal(linear_index)
gen prob_leaving2 = prob_leaving^2
gen prob_leaving3 = prob_leaving^3
gen prob_leaving4 = prob_leaving^4
gen prob_leaving5 = prob_leaving^5
gen prob_leaving6 = prob_leaving^6 
tsset mbr_sys_id year
***** *****

*reghdfe mean_premium yeardum* (mean_pred_riskscore_rp = mean_ORS_riskscore_rp), absorb(mbr_sys_id) vce(cluster customer_number year)
reghdfe mean_premium mean_pred_riskscore_rp  yeardum* , absorb(mbr_sys_id) vce(cluster customer_number year)
gen sample = e(sample)



**** CREATE COMPETITION VARIALES 
gen hhi = hhi2013 if year==2013
replace hhi=hhi2014 if year==2014
replace hhi=hhi2015 if year==2015

gen leader = leader2013 if year==2013
replace leader= leader2014 if year==2014
replace leader= leader2015 if year==2015

gen numfirms5more = numfirms5more2013 if year==2013
replace numfirms5more=numfirms5more2014 if year==2014
replace numfirms5more=numfirms5more2015 if year==2015

*create interacted variables 
gen hhi_interacted_score = hhi * mean_pred_riskscore

gen hhi_interacted_score_rp  = hhi * mean_pred_riskscore_rp

gen leader_interacted_score = leader * mean_pred_riskscore

gen leader_interacted_score_rp = leader * mean_pred_riskscore_rp

gen numfirms5more_int = numfirms5more * mean_pred_riskscore

gen numfirms5more_intrp = numfirms5more * mean_pred_riskscore_rp


*********************************************************************************
**** TABLE HHI  (COMPETITION)
*********************************************************************************
reghdfe mean_premium mean_pred_riskscore_rp yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod1
reghdfe mean_premium  mean_pred_riskscore_rp hhi yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod2
reghdfe mean_premium  mean_pred_riskscore_rp hhi_interacted_score_rp hhi prob_leaving*  yeardum* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod3
****************************************************************************************************************** fragment
*********TABLE 
esttab mod1 mod2 mod3  using TableC1_Panel1.tex , replace label    nonotes nonumbers stats(N, fmt(%12.0fc)) compress cells(b(star fmt(%12.0fc %12.3fc ) label(" ")) se(fmt( %12.0fc %12.3fc) label(" ") par) ) collabels(none) nogaps  ///
		title(ACG Score and Claims Pass-through to Premiums) mtitles("I" "II" "III") ///
		star(* 0.10 ** 0.05 *** 0.01)  ///
		keep( mean_pred_riskscore_rp hhi hhi_interacted_score_rp  ) ///
		prefoot( \hline "Dep. Var. & Premium & Premium & Premium" \\ /// 
		"Firm FE & Yes & Yes & Yes "\\ ///		
		"Year FE & Yes & Yes & Yes" \\  \hline) 
eststo clear
*********************************************************************************************


*********************************************************************************
**** TABLE SHARE OF THE LEADER FIRM  (COMPETITION)
*********************************************************************************
reghdfe mean_premium mean_pred_riskscore_rp yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod1
reghdfe mean_premium mean_pred_riskscore_rp leader yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod2
reghdfe mean_premium  mean_pred_riskscore_rp leader_interacted_score_rp leader  yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod3
****************************************************************************************************************** fragment
*********TABLE 
esttab mod1 mod2 mod3  using TableC1_Panel2.tex.tex , replace label    nonotes nonumbers stats(N, fmt(%12.0fc)) compress cells(b(star fmt(%12.0fc %12.3fc ) label(" ")) se(fmt( %12.0fc %12.3fc) label(" ") par) ) collabels(none) nogaps  ///
		title(ACG Score and Claims Pass-through to Premiums) mtitles("I" "II" "III") ///
		star(* 0.10 ** 0.05 *** 0.01)  ///
		keep( mean_pred_riskscore_rp leader leader_interacted_score_rp  ) ///
		prefoot( \hline "Dep. Var. & Premium & Premium & Premium" \\ /// 
		"Firm FE & Yes & Yes & Yes "\\ ///		
		"Year FE & Yes & Yes & Yes" \\  \hline) 
eststo clear
*********************************************************************************************

 


**********************************************************
**** TABLE NUMBER OF FIRMS MORE THAN 5%   (COMPETITION)
*********************************************************************************
reghdfe mean_premium mean_pred_riskscore_rp yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod1
reghdfe mean_premium mean_pred_riskscore_rp numfirms5more yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod2
reghdfe mean_premium mean_pred_riskscore_rp numfirms5more_intrp numfirms5more  yeardum* prob_leaving* if sample==1, absorb(mbr_sys_id) cluster(customer_number year)
eststo mod3
****************************************************************************************************************** fragment
*********TABLE 
esttab mod1 mod2 mod3  using TableC1_Panel3.tex , replace label    nonotes nonumbers stats(N, fmt(%12.0fc)) compress cells(b(star fmt(%12.0fc %12.3fc ) label(" ")) se(fmt( %12.0fc %12.3fc) label(" ") par) ) collabels(none) nogaps  ///
		title(ACG Score and Claims Pass-through to Premiums) mtitles("I" "II" "III") ///
		star(* 0.10 ** 0.05 *** 0.01)  ///
		keep( mean_pred_riskscore_rp numfirms5more numfirms5more_intrp  ) ///
		prefoot( \hline "Dep. Var. & Premium & Premium & Premium" \\ /// 
		"Firm FE & Yes & Yes & Yes "\\ ///		
		"Year FE & Yes & Yes & Yes" \\  \hline) 
eststo clear
****************************


exit 

